package fleetAdmin;

import java.util.ArrayList;

public class TestCommuter {
	
	
	//this is a list that holds all planes in stock
	private static ArrayList planesInStock = new ArrayList();
	
	// MAIN
	public static void main(String[] args) {
		//Add some planes to the list
		planesInStock.add(new PassAircraft("Fokker", "50", "PH-QKM", 2, 50));
		planesInStock.add(new PassAircraft("Fokker", "100", "PA-CPM", 2, 85));
		
		//show what planes have been bought
		listPlanes();
		
		//Sell a plane
		planesInStock.remove(0);
		System.out.println("Sold Aircraft # 0 ...");System.out.println();
		listPlanes();
		
		//change passengers in the 2nd plane 
		System.out.println("Reaganging plane # 0");System.out.println();
		//get the plane out of the list an put it in a tmp variable
		PassAircraft passaircraft = (PassAircraft) planesInStock.get(0);
		System.out.println("BEFORE MOD:" + passaircraft);
		//change the paggengers
		passaircraft.setPassengers(62);
		System.out.println("It now has " + passaircraft.getPassengers() + " passengers");
		
		//Add some more planes ...
		System.out.println("Adding planes ...");System.out.println();
		//adding normal planes
		planesInStock.add(new PassAircraft("Saab","A model", "PT-HIO", 3, 120));
		planesInStock.add(new PassAircraft());
		//adding a mixed plane
		planesInStock.add(new MixedAircraft("Airbus", "A320", "HF-NOP", 2, 150, 8));
		listPlanes();
		
		//test mixed aircraft ... 
		//Get the mixed aircraft and put it in a tmp variable
		MixedAircraft mixedAircraft = (MixedAircraft) planesInStock.get(planesInStock.size()-1);
		System.out.println("Current aircraft load:"+mixedAircraft.getFreight());
		//set the load of the plane
		mixedAircraft.setFreight(16.2);
		System.out.println("New aircraft load:"+mixedAircraft.getFreight());
		
		//add a photoplane
		planesInStock.add(new PhotoAircraft());
		
		//put the photoplane in a tmp variable
		PhotoAircraft photoplane = (PhotoAircraft) planesInStock.get(planesInStock.size()-1);
		System.out.println("Give the photoAircraft some camera's (before):"+ photoplane.getContiansHasselblad() +" / "+photoplane.getContainsNikon());
		//give the plane two camra's
		photoplane.setContiansHasselblad(true);
		photoplane.setContiansNikon(true);
		System.out.println("after:"+ photoplane.getContiansHasselblad() +" / "+photoplane.getContainsNikon());
		System.out.println();
		
		
		System.out.println("final result:");
		listPlanes();
	}

	private static void listPlanes() {
		System.out.println("Listing planes:");
		System.out.println(" # \tPLANE");
		System.out.println("-------------------------------------------------------------------------");
		
		for (int planeIndex = 0; planeIndex < planesInStock.size(); planeIndex++) {
			System.out.println(" " + planeIndex + "\t" + planesInStock.get(planeIndex));
		}
		System.out.println();
	}

}
